package summarizer.newversion;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

import thesis.DataObject;
import thesis.Summary;

public class RandomSummarizer extends Summarizer {

	@Override
	public Summary computeSummary(int summaryDimension, int numberOfPages,
			HashMap<Long, DataObject> tweets, int dimSize) {
		ArrayList<DataObject> allTweets = new ArrayList<DataObject>();
		for (DataObject t : tweets.values()) {
			allTweets.add(t);
		}
		return RandomSummarizer.randomSummary(summaryDimension, allTweets);
	}

	public static Summary randomSummary(int summaryDimension,
			ArrayList<DataObject> allTweets) {
		ArrayList<DataObject> result = new ArrayList<DataObject>();
		for (int i = 0; i < summaryDimension; i++) {
			result.add(allTweets.get(i));
		}
		for (int i = summaryDimension; i < allTweets.size(); i++) {
			int ind = new Random().nextInt(i + 1);
			if (ind < summaryDimension) {
				result.set(ind, allTweets.get(i));
			}
		}
		Summary summary = new Summary();
		for (DataObject t : result) {
			summary.addMemoryTweet(t);
		}
		return summary;
	}

	public RandomSummarizer() {
		rndAlgo = true;
	}

	public String toString() {
		return "Random Summarizer";
	}

	@Override
	public long getExecutionTime() {
		// TODO Auto-generated method stub
		return executionTime;
	}

}
